package com.gpzx.zx.module.home.ui.adapter

import android.content.Context
import androidx.recyclerview.widget.RecyclerView
import com.bumptech.glide.Glide
import com.gpzx.zx.R
import com.gpzx.zx.databinding.ItemNews24Binding
import com.gpzx.zx.databinding.ItemXnbBinding
import com.wkq.lib_base.adapter.KtDataBindingAdapter
import com.wkq.lib_base.adapter.KtDataBindingViewHolder
import com.wu.common.utils.site.XnbInfo
import kotlinx.android.synthetic.main.activity_web_news.view.*

/**
 * 作 者 : wkq
 *
 * 时 间 : 2021/1/7 13:34
 *
 * 名 字 : XnbAdapter
 *
 * 简 介 :
 *
 */
class XnbAdapter(mContext: Context, layoputId: Int): KtDataBindingAdapter<XnbInfo>(mContext,layoputId) {

    override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
        super.onBindViewHolder(holder, position)
        var bindingHolder = holder as KtDataBindingViewHolder
        var binding = bindingHolder.viewBinding as ItemXnbBinding
        binding.data=getItem(position)
        Glide.with(mContext).load(getItem(position)!!.xnbIcon).into(binding.ivIcon)

        if (getItem(position)!!.xnb24ZF.startsWith("-")){
            binding.rlPrice.setBackgroundColor(mContext.resources.getColor(R.color.color_s))
        }else{
            binding.rlPrice.setBackgroundColor(mContext.resources.getColor(R.color.color_23d41e))
        }

    }
}